<template>
  <div>
    <el-container>
      <el-header class="layout-header">
        <el-menu
            router
            :default-active="activeIndex2"
            class="el-menu-demo"
            mode="horizontal"
            @select="handleSelect"
            background-color="#ec6c0a"
            text-color="#fff"
            active-text-color="#ffd04b"
            style="margin: auto 400px">
          <el-menu-item index="/worker/index">我的信息</el-menu-item>
          <el-button type="warning" @click="goToindex">去首页</el-button>

          <el-submenu index="1" mode="horizontal">
            <template slot="title">订单服务管理</template>
            <el-menu-item index="/worker/viewOrder">查看订单</el-menu-item>
            <el-menu-item index="/worker/addServe">新建服务</el-menu-item>
          </el-submenu>

          <el-submenu index="2" mode="horizontal">
            <template slot="title">账户设置</template>

            <el-submenu index="2-1">
              <template slot="title">安全设置</template>
              <el-menu-item index="/worker/upPassword">修改登录密码</el-menu-item>
              <el-menu-item index="/worker/setPhone">手机绑定</el-menu-item>
            </el-submenu>

            <el-submenu index="2-2">
              <template slot="title">个人资料</template>
              <el-menu-item index="/worker/upAddress">收货地址</el-menu-item>
              <el-menu-item index="/worker/upInfo">修改昵称、头像</el-menu-item>
            </el-submenu>
          </el-submenu>
        </el-menu>


      </el-header >
      <el-main class="layout-main">
        <router-view/>
      </el-main>
    </el-container>

  </div>
</template>

<style>
.layout-header {
  background: #ec6c0a;
}

.layout-header h1 {
  color: #fff;
  line-height: 60px;
}


.layout-body {
  position: absolute;
  top: 60px;
  bottom: 0;
  left: 0;
  right: 0;
}

.layout-aside {
  background: #222;
}

.layout-aside i {
  color: #fff !important;
}

.layout-main {
  margin: auto 400px;
  background: #fff;
}

.el-menu-item.is-active {
  background: #2d3c4d !important;
}
</style>

<script>
export default {
  name: "WorkerView",
  data(){
    return {
      currentIndex: "",
      id: ""
    };
  },
  methods:{
    goToindex() {
      console.log("点了")
      var path = this.$route.path;
      if (path!="/"){
        this.$router.push({name:"index"})
      }

  },
  },
  mounted() {
    this.id=this.$route.query.workId;
    console.log('当前的用户id：',this.id)
    console.log("初始化3“：")

  },
  watch: {
    '$route'() {
      console.log("初始化2“：")


    }
  },
}
</script>